Introduction
caution
This document is for TimeBase Enterprise Edition 5.4 and earlier.
QuantQuery Language (QQL) is a query language designed to extract, filter, aggregate and transform data in TimeBase streams.
While QQL is very similar to SQL, there are very significant differences. QQL is designed to query polymorphic time-series data, while SQL is designed primarily for querying monomorphic (fixed-structure) data, without any time-series properties.
Getting Started
We suggest using Demo streams for demonstration purposes to guide you through QQL language. Most of examples in this tutorial are based on demo streams.
Import Demo Streams
To quickly get started with QQL, download and unzip the below archive file to any folder on your computer. Launch TimeBase and import demo streams.
Launch TimeBase and TimeBase Web Admin. You can use either TimeBase Installer or run in Docker or see other deployment options.
Run TimeBase Shell by double-clicking
tickdb.cmd
frombin
folder.- Set database
==> set db dxtick://localhost:8011
==> open Download demo streams and import them to TimeBase:
Run this in TimeBase Shell to import demo streams to TimeBase serveropen rw
set src C:\path to a stream file\binance.qsmsg.gz
set tz GMT
import binance
open rw
set src C:\path to a stream file\orders.qsmsg.gz
set tz GMT
import orders
open rw
set src C:\path to a stream file\tickquerydemo.qsmsg.gz
set tz GMT
import tickquerydemo
open rw
set src C:\path to a stream file\packages.qsmsg.gz
set tz GMT
import packages
open rw
set src C:\path to a stream file\securities.qsmsg.gz
set tz GMT
import securitiesUse TimeBase Shell console to run QQL commands.
Use also TimeBase Web Admin application to run QQL commands.
note
In this tutorial we will provide, for demonstration purposes, query examples in TimeBase Shell format and screenshots from TimeBase Web Admin application.
info
Refer to Quick Start to learn how to start TimeBase in a few simple steps.
Using TimeBase Shell
Run TimeBase Shell by double-clicking tickdb.cmd
from bin
folder. After you start TimeBase Shell, it displays a console window with a prompt. You can type or paste in various commands, and the Shell will respond. Use TimeBase Shell Guide to learn more about TimeBase Shell available commands.
QQL queries return a sequence of stream messages ordered by time. Every time the type of message changes, you see a heading row, such as:
>deltix.timebase.api.messages.BestBidOfferMessage,TIMESTAMP,SYMBOL,TYPE,offerPrice,offerSize,bidPrice,bidSize
In the first cell, you see the "greater" sign, followed by the class name of the message. Next, you see standard field headings TIMESTAMP, SYMBOL and TYPE. The following headings, if any, contain field names declared in the message class.
Lines following the header line contain message data. The first column contains the sequential number of a message (not counting header lines, of course). The rest of the columns contain data values according to the headings.
Every query returns messages, and every message in TimeBase has the class name, the timestamp, and the symbol/type combination, collectively called the entity identity. See Messages to learn more.
==> select * from tickquerydemo
>deltix.qsrv.hf.pub.BestBidOfferMessage,TIMESTAMP,SYMBOL,TYPE,offerPrice,offerSize,bidPrice,bidSize
0,2011-10-17 17:21:40,GREATCO,EQUITY,43.5,100.0,42.5,200.0
1,2011-10-17 17:21:40,XBANK,EQUITY,301.75,40000.0,301.25,800.0
>deltix.qsrv.hf.pub.TradeMessage,TIMESTAMP,SYMBOL,TYPE,price,size
2,2011-10-17 17:21:41,XBANK,EQUITY,301.25,800.0
>deltix.qsrv.hf.pub.BestBidOfferMessage,TIMESTAMP,SYMBOL,TYPE,offerPrice,offerSize,bidPrice,bidSize
3,2011-10-17 17:21:42,XBANK,EQUITY,301.5,60000.0,298.5,800.0
4,2011-10-17 17:21:43,GREATCO,EQUITY,45.0,100.0,43.0,400.0
5,2011-10-17 17:21:43,XBANK,EQUITY,299.5,40000.0,295.0,300.0
>deltix.qsrv.hf.pub.TradeMessage,TIMESTAMP,SYMBOL,TYPE,price,size
6,2011-10-17 17:21:44,GREATCO,EQUITY,44.0,100.0
info
See TimeBase Shell Guide for more information.
Using TimeBase Web Admin
TimeBase Web Admin application allows viewing streams, stream schemas, creating and editing streams, placing QQL queries and many other operations.
info
See TimeBase Web Admin for more information on running QQL queries in Web Admin application.